# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-x509
_pkgname=x509
pkgver=0.16.0
pkgrel=1
pkgdesc="Public Key Infrastructure (RFC 5280, PKCS) purely in OCaml"
url="https://github.com/mirleft/ocaml-x509"
arch="all !riscv64"  # limited by ocaml aport
license="BSD-2-Clause"
depends="
	ocaml-runtime
	ocaml-asn1-combinators
	ocaml-base64
	ocaml-cstruct
	ocaml-domain-name
	ocaml-fmt
	ocaml-gmap
	ocaml-ipaddr
	ocaml-logs
	ocaml-mirage-crypto
	ocaml-pbkdf
	ocaml-ptime
	"
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	ocaml-asn1-combinators-dev
	ocaml-base64-dev
	ocaml-cstruct-dev
	ocaml-domain-name-dev
	ocaml-fmt-dev
	ocaml-gmap-dev
	ocaml-ipaddr-dev
	ocaml-logs-dev
	ocaml-mirage-crypto-dev
	ocaml-pbkdf-dev
	ocaml-ptime-dev
	"
makedepends="$depends_dev dune ocaml"
checkdepends="ocaml-alcotest-dev ocaml-cstruct-unix-dev"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/mirleft/ocaml-x509/releases/download/v$pkgver/x509-$pkgver.tbz"
builddir="$srcdir/$_pkgname-$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
c9b4cf55d16d8b1e6b6faa18fc9ac08065fa09937f07a3447d4b637539b37bea6374c98d184eba159a8ba8eba860303a78563097e47ef30529fedaaf722115c6  ocaml-x509-0.16.0.tar.bz2
"
